<template>
    <div class="wrap">
        <div class="inner">
            <el-carousel 
                height="650px" 
                indicator-position="none" 
                arrow="never" 
                ref="carouselDetail"
                :initial-index="current"
                @change="i => current = i">
                <el-carousel-item v-for="item in info.link" :key="item" class="carouselItem" >
                    <img :src="item"/>
                    <div class="infoCard" :style="{width:isOpen?'':0,opacity:isOpen?'':0}">
                        <p class="title">北京大兴国际机场</p>
                        <p class="location">北京市大兴区</p>
                        <p class="date">2014年12月</p>
                        <p class="content">
                            北京大兴国际机场（Beijing Daxing International Airport，IATA：PKX，ICAO：ZBAD），为4F级民用机场 [1]  ；位于中国北京市大兴区与河北省廊坊市广阳区交界处，距离北京天安门46千米 [2]  ，距离廊坊市26千米 [2]  ，距离雄安新区55千米 [3]  ，距离首都机场67千米 [4]  ；定位为大型国际航空枢纽、国家发展一个新的动力源、支撑雄安新区建设的京津冀区域综合交通枢纽 [5]  。
                        </p>
                        <p class="progress">{{current+1}}/{{info.link.length}}</p>
                        <img src="@/assets/img/case/close_1.png" class="close" @click="setIsOpen">
                    </div>
                    <img src="@/assets/img/case/left_a1.png" class="left" @click="prev">
                    <img src="@/assets/img/case/right_a1.png" class="right" :style="{right:isOpen?'360px':''}" @click="next">
                    <img src="@/assets/img/case/close_1.png" class="cardTurn" v-if="!isOpen" @click="setIsOpen">
                </el-carousel-item>
            </el-carousel>
        </div>
        <div class="close" @click="close">
            <img src="@/assets/img/case/close.png">
        </div>
    </div>
</template>

<script>
    export default {
        props:['info'],
        data(){
            return {
                isOpen:true,
                current:0
            }
        },
        mounted(){
            const Body = document.querySelector('body');
            Body.style.overflow = 'hidden';
            Body.style.paddingRight = '17px';
        },
        computed:{
            carousel(){
                const dom = this.$refs.carouselDetail;
                return dom;
            }
        },
        destroyed(){
            const Body = document.querySelector('body');
            Body.style.overflow = '';
            Body.style.paddingRight = '';
        },
        methods:{
            setIsOpen(){
                this.isOpen = !this.isOpen;
            },
            prev(){
                this.carousel.prev();
            },
            next(){
                this.carousel.next();
            },
            close(){
                this.$emit('close');
            }
        }
    }
</script>

<style lang="less" scoped>
.wrap {
    z-index: 999;
    background-color: rgba(0,0,0,.3);
    position: fixed;
    top:0;
    left: 0;
    bottom: 0;
    right: 0;
    .carouselItem {
        position: relative;
        &>img {
            width: 1000px;
            height: 650px;
        }
        .infoCard {
            transition: all .2s ease-in-out;
            height: 100%;
            width: 350px;
            background-color: rgba(27,117,189,.8);
            position: absolute;
            right: 0;
            top: 0;
            padding: 73px 20px 20px 32px;
            text-align: left;
            color: #fff;
            box-sizing: border-box;
            opacity: 1;
            .title {
                font-size:30px;
                font-weight:400;
                color:rgba(255,255,255,1);
                line-height:24px;
                margin-bottom: 18px;
            }
            .location,.date{
                font-size:12px;
                font-weight:400;
                color:rgba(255,255,255,1);
                line-height:24px;
                margin-bottom: 9px;
            }
            .date {
                margin-bottom: 30px;
            }
            .content {
                font-size:12px;
                font-weight:400;
                color:rgba(255,254,254,1);
                line-height:24px;
            }
            .progress {
                position:absolute;
                text-align: right;
                bottom: 20px;
                right: 20px;
                width: 100px;
                font-size:20px;
                line-height:24px;
            }
            .close {
                width: 12px;
                height: 60px;
                position: absolute;
                left: 0;
                top: 50%;
                margin-top: -30px;
            }
        }
        .left,.right {
            position: absolute;
            top:50%;
            left: 10px;
            width: 48px;
            height: 48px;
            margin-top: -24px;
            cursor: pointer;
        }
        .right {
            right: 22px;
            left: auto;
        }
        .cardTurn {
            width: 12px;
            height: 60px;
            position: absolute;
            right: 0;
            top: 50%;
            margin-top: -30px;
            transform: rotateY(180deg);
            cursor: pointer;
        }
    }
    .inner {
        width: 1000px;
        height: 650px;
        background-color: pink;
        position: relative;
        top: 10vh;
        margin: 0 auto;
    }
    .close {
        margin-top: 20px;
        position: relative;
        top: 10vh;
        cursor: pointer;
        img {
            width: 40px;
            height: 40px;
        }
    }
}
</style>